<?php
namespace Admin\Controller;
use Think\Controller;
class InterfaceController extends Controller {

	   public function test()
     {

      	$this->display();
     } 

     //所有俱乐部简介
     public function clubintr()
     {

        if(I("get.flag")==0)
        {

         	 $intr=M('clubintr');
           $list = $intr->select();
           //var_dump($list);
           foreach($list as $key=>$value)
           { 
    	         	foreach($value as $key2=>$value2){ 

    			         $list[$key][$key2] = urlencode ( $value2 ); //编码
    			      }
    	     } 
    	   
    	     echo urldecode ( json_encode($list));
        }
     }

      //具体俱乐部简介
     public function clubintrdetail()
     {

         $clubintr_id = I("get.clubintr_id");
         //var_dump( $clubintr_id);
         $intr=M('clubintr');
         $list = $intr->where("clubintr_id = $clubintr_id ")->select();
         //var_dump($list);
         foreach($list as $key=>$value)
         { 
              foreach($value as $key2=>$value2){ 

                 $list[$key][$key2] = urlencode ( $value2 ); //编码
              }
         } 
       
         echo urldecode ( json_encode($list));
     }

     //具体教练简介
     public function teacherintr()
     {

         $clubintr_id = I("get.clubintr_id");
         //var_dump( $clubintr_id);
         $intr=M('teacher');
         $list = $intr->where("clubintr_id = $clubintr_id ")->select();
         //var_dump($list);
         foreach($list as $key=>$value)
         { 
              foreach($value as $key2=>$value2){ 

                 $list[$key][$key2] = urlencode ( $value2 ); //编码
              }
         } 
       
         echo urldecode ( json_encode($list));
     }

      //获取精品课程信息
     public function clubcourse()
     {

         $clubintr_id = I("get.clubintr_id");
         //var_dump( $clubintr_id);
         $intr=M('clubcourse');
         $list = $intr->where("clubintr_id = $clubintr_id ")->select();
         //var_dump($list);
         foreach($list as $key=>$value)
         { 
              foreach($value as $key2=>$value2){ 

                 $list[$key][$key2] = urlencode ( $value2 ); //编码
              }
         } 
       
         echo urldecode ( json_encode($list));
     }

      //获取俱乐部样例视频
     public function examplevideo()
     {

         $clubintr_id = I("get.clubintr_id");
         //var_dump( $clubintr_id);
         $intr=M('examplevideo');
         $list = $intr->where("clubintr_id = $clubintr_id ")->select();
         //var_dump($list);
         foreach($list as $key=>$value)
         { 
              foreach($value as $key2=>$value2){ 

                 $list[$key][$key2] = urlencode ( $value2 ); //编码
              }
         } 
       
         echo urldecode ( json_encode($list));
     }

      //获取所有图片信息接口
     public function pictureinf()
     {

         $intr=M('pictureinf');
         $list = $intr->select();
         //var_dump($list);
        
         //构造嵌套数组
         foreach($list as $key=>$value)
         { 
              foreach($value as $key2=>$value2){ 

                 if($key2=='usr_id')
                 {
                    $uintr=M('users');
                    $uid = $list[$key][$key2];
                    $uinf= $uintr->where("usr_id = $uid ")->select();
                    //var_dump($uinf);
                    $list[$key]['users'] = $uinf;
                 }
              }
         } 

         //重编码与解码
         foreach($list as $key=>$value)
         { 
              foreach($value as $key2=>$value2)
              { 

                 if($key2=='users')
                 {
                    foreach ($value2 as $key3 => $value3)
                    {

                      foreach ($value3 as $key4 => $value4) 
                      {
                        $value2[$key3][$key4] = urlencode ( $value4 );
                      }
                    }
                 }
                 else{

                    $list[$key][$key2] = urlencode ( $value2 ); //编码
                 }
              }
         } 
        
        echo urldecode ( json_encode($list));
     }

      //获取具体图片信息接口
     public function pictureinfdetail()
     {

         $picinf_id = I("get.picinf_id");
         $intr=M('pictureinf');
         $list = $intr->where("picinf_id = $picinf_id")->select();
         //var_dump($list);
        
         //构造嵌套数组
         foreach($list as $key=>$value)
         { 
              foreach($value as $key2=>$value2){ 

                 if($key2=='usr_id')
                 {
                    $uintr=M('users');
                    $uid = $list[$key][$key2];
                    $uinf= $uintr->where("usr_id = $uid ")->select();
                    //var_dump($uinf);
                    $list[$key]['users'] = $uinf;
                 }
              }
         } 

         //重编码与解码
         foreach($list as $key=>$value)
         { 
              foreach($value as $key2=>$value2)
              { 

                 if($key2=='users')
                 {
                    foreach ($value2 as $key3 => $value3)
                    {

                      foreach ($value3 as $key4 => $value4) 
                      {
                        $value2[$key3][$key4] = urlencode ( $value4 );
                      }
                    }
                 }
                 else{

                    $list[$key][$key2] = urlencode ( $value2 ); //编码
                 }
              }
         } 
        
        echo urldecode ( json_encode($list));
     }

     //获取评论/回复信息
     public function piccomment()
     {

         $picinf_id = I("get.picinf_id");
         $intr=M('piccomment');
         $list = $intr->where("picinf_id = $picinf_id ")->select();
        
         foreach($list as $key=>$value)
         { 
              foreach($value as $key2=>$value2){ 

                 $list[$key][$key2] = urlencode ( $value2 ); //编码
              }
         } 
       
         echo urldecode ( json_encode($list));
     }

      //获取所有大师信息列表
     public function greatintr()
     {

         $flag = I("get.flag");
         if($flag == 1)
         {
           $intr=M('greatintr');
           $list = $intr->select();
          
           foreach($list as $key=>$value)
           { 
                foreach($value as $key2=>$value2){ 

                   $list[$key][$key2] = urlencode ( $value2 ); //编码
                }
           } 
         
           echo urldecode ( json_encode($list));
         }
        
     }

     //获取具体大师信息
     public function greatintrdetail()
     {
         $greatintr_id = I("get.greatintr_id");
         $intr=M('teacher');//大师具体信息存储在教练表中
         $list = $intr->where("teacher_id = $greatintr_id")->select();
        
         foreach($list as $key=>$value)
         { 
              foreach($value as $key2=>$value2){ 

                 $list[$key][$key2] = urlencode ( $value2 ); //编码
              }
         } 
       
         echo urldecode ( json_encode($list));
           
     }

     //获取大师课堂视频信息
     public function coursevideo()
     {
         $greatintr_id = I("get.greatintr_id");
         $intr=M('coursevideo');//大师具体信息存储在教练表中
         $list = $intr->where("greatintr_id = $greatintr_id")->select();
        
         foreach($list as $key=>$value)
         { 
              foreach($value as $key2=>$value2){ 

                 $list[$key][$key2] = urlencode ( $value2 ); //编码
              }
         } 
       
         echo urldecode ( json_encode($list));
           
     }

      //获取大师提问模块信息
     public function gquestion()
     {
         $greatintr_id = I("get.greatintr_id");
         $intr=M('gquestion');//大师具体信息存储在教练表中
         $list = $intr->where("greatintr_id = $greatintr_id")->select();
        
         foreach($list as $key=>$value)
         { 
              foreach($value as $key2=>$value2){ 

                 $list[$key][$key2] = urlencode ( $value2 ); //编码
              }
         } 
       
         echo urldecode ( json_encode($list));
           
     }


}